import org.mmtk.utility.heap.HeapGrowthManager;
import org.mmtk.vm.VM;

public class SimpleImpulseTest {

	public int objectSize = 1 * 1024 * 1024; // size in bytes
	
	public long counter = 0;
	
	private SmallObject s;
	
	class SmallObject {
		int a[];
		public SmallObject() {
			a = new int[objectSize / 4];
			for (int i=0;i<a.length;i++) {
				a[i] = i;
			}
		}
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		SimpleImpulseTest sit = new SimpleImpulseTest();
		
		double s = VM.statistics.nanosToMillis(VM.statistics.nanoTime());
		sit.go();
		double t = VM.statistics.nanosToMillis(VM.statistics.nanoTime()) - s;
		System.out.println("Time: " + t);
		
	}
	
	public void go() {
		
		while (counter < 20000) {
			
			s = new SmallObject();
			counter++;
			
			if (counter % 1000 == 0)
				System.out.println(counter);
			
			if (counter == 10000) {
				HeapGrowthManager.readyForImpulse();
			}
			
		}
		
				
	}
	
}
